home *** CD-ROM | disk | FTP | other *** search
/ Mac Power 1997 December / MACPOWER-1997-12.ISO.7z / MACPOWER-1997-12.ISO / AMUG / PROGRAMMING / Raven 1.2 Examples.sit / Raven 1.2 Examples / Quill / Source / Main.cpp < prev    next >
C/C++ Source or Header  |  1997-02-21  |  4KB  |  168 lines

  1. /*
  2.  *  File:       Main.cpp
  3.  *  Summary:       The big enchilada.
  4.  *  Written by: Jesse Jones
  5.  *
  6.  *  Copyright ゥ 1996 Jesse Jones. Permission to use, copy, modify, and distribute this
  7.  *    file as source or object code is hereby granted without fee. Permission to sell the
  8.  *    source code is granted only to non-profit institutions. This file is provided 'as is' 
  9.  *    without express or implied warranty. 
  10.  *
  11.  *  Change History (most recent first):    
  12.  *
  13.  *         <->     2/24/96    JDJ        Created.
  14.  */
  15.  
  16. #include <List.h>
  17.  
  18. #include <ZAppBootStrap.h>
  19. #include <ZFloatingDesktop.h>
  20. #include <ZGestalt.h>
  21. #include <ZMemoryHeap.h>
  22. #include <ZNewAndDelete.h>
  23. #include <ZPreferences.h>
  24. #include <ZStringUtils.h>
  25.  
  26. #if RAVEN_OPERATOR_NEW
  27. #include <ZBestFitAllocator.h>
  28. #include <ZMemoryHeap.h>
  29. #include <ZNewAndDelete.h>
  30. #include <ZSimpleAllocator.h>
  31. #endif
  32.  
  33. #include "Application.h"
  34.  
  35.  
  36. // ===================================================================================
  37. //    class TBootStrap
  38. // ===================================================================================
  39.  
  40. //---------------------------------------------------------------
  41. //
  42. // TBootStrap::DoEarlyInit
  43. //
  44. //---------------------------------------------------------------
  45. void TBootStrap::DoEarlyInit()
  46. {
  47.     const long  kInitialObjectHeapSize   = 1500*1024L;
  48.     const long  kObjectHeapIncrementSize = 32*1024L;        
  49.     const short    kNumMasterPtrBlocks      = 10;
  50.  
  51.     for (short i = 1; i <= kNumMasterPtrBlocks; i++)
  52.         MoreMasters();
  53.  
  54. #if RAVEN_OPERATOR_NEW                                    // on by default
  55.     ASSERT(gObjectHeap == nil);
  56.     
  57.     TAllocator* alloc = new TBestFitAllocator(kInitialObjectHeapSize, kObjectHeapIncrementSize);
  58.     gObjectHeap = new TMemoryHeap(alloc);
  59.  
  60. #else
  61.     _prealloc_newpool(kInitialObjectHeapSize);
  62.     _set_newpoolsize(kObjectHeapIncrementSize);
  63.     _set_newnonptrmax(kObjectHeapIncrementSize/4);
  64. #endif
  65. }
  66.  
  67. #pragma mark -
  68.  
  69. // ===================================================================================
  70. //    class CMyBooter
  71. // ===================================================================================
  72. class CMyBooter : public TAppBootStrap {
  73.     
  74.     typedef TAppBootStrap Inherited;
  75.     
  76. //-----------------------------------
  77. //    Initialization/Destruction
  78. //
  79. public:
  80.     virtual             ~CMyBooter();
  81.     
  82.                           CMyBooter();
  83.  
  84. //-----------------------------------
  85. //    Inherited API
  86. //
  87. protected:
  88.     virtual void         OnSystemNeeds(list<string, allocator<string> >& needs);
  89.  
  90.     virtual void         OnBoot();
  91. };
  92.  
  93.  
  94. //---------------------------------------------------------------
  95. //
  96. // CMyBooter::~CMyBooter
  97. //
  98. //---------------------------------------------------------------
  99. CMyBooter::~CMyBooter()
  100. {
  101. }
  102.  
  103.  
  104. //---------------------------------------------------------------
  105. //
  106. // CMyBooter::CMyBooter
  107. //
  108. //---------------------------------------------------------------
  109. CMyBooter::CMyBooter()
  110. {
  111.     mIdealDisplayMode = SDisplayMode(640, 480, 8);
  112. }
  113.  
  114.  
  115. //---------------------------------------------------------------
  116. //
  117. // CMyBooter::OnSystemNeeds
  118. //
  119. //---------------------------------------------------------------
  120. void CMyBooter::OnSystemNeeds(list<string, allocator<string> >& needs)
  121. {
  122.     Inherited::OnSystemNeeds(needs);
  123.  
  124.     if (!UGestalt::hasDragMgr)
  125.         needs.push_back(LoadIndString(257, 5));                
  126. }
  127.  
  128.  
  129. //---------------------------------------------------------------
  130. //
  131. // CMyBooter::OnBoot
  132. //
  133. //---------------------------------------------------------------
  134. void CMyBooter::OnBoot()
  135. {
  136.     Inherited::OnBoot();
  137.     
  138.     gObjectHeap->AddAllocator(20, 2000);
  139.     gObjectHeap->AddAllocator(16,  500);
  140.     gObjectHeap->AddAllocator(12, 1500);
  141.  
  142.     TFloatingDesktop::Init();    
  143.  
  144.     UPreferences::Init(LoadIndString(257, 6), 'QUIL');
  145. }
  146.  
  147. #pragma mark -
  148.  
  149. //---------------------------------------------------------------
  150. //
  151. // Main
  152. //
  153. //---------------------------------------------------------------
  154. void main()
  155. {
  156.     CMyBooter booter;
  157.     booter.Boot();
  158.         
  159. //    (void) new int;
  160.             
  161.     {
  162.     CApplication theApp;
  163.         theApp.Run();                    
  164.     }
  165. }
  166.  
  167.  
  168.